package com.mp.approvalreq.dao;

import com.mp.approvalreq.entity.Flow;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * @author xq
 */
public interface FlowDao {

    /**
     * 保存审批流
     *
     * @param flows
     * @throws SQLException
     */
    void insertFlows(List<Flow> flows) throws SQLException;

    /**
     * 根据审批id获取审批流
     *
     * @param requestId
     * @return
     * @throws SQLException
     */
    List<Flow> selectFlowsByRequestId(Integer requestId) throws SQLException;

	/**
     * 修改审批状态（作废审批流）
     *
     * @param requestId
     * @param companyId
     * @throws SQLException
     */
    void updateFlowState(Integer requestId, Integer companyId) throws SQLException;

    /**
     * 查询用户待处理的审批id
     *
     * @param companyId
     * @param companyInfoId
     * @return
     * @throws SQLException
     */
    List<Integer> selectNeedUserApproveIds(Integer companyId, Integer companyInfoId) throws SQLException;

    /**
     * 查询用户待批准的审批id（无排序，给红点的）
     *
     * @param companyId
     * @param companyInfoId
     * @return
     * @throws SQLException
     */
    List<Integer> selectNeedUserApproveIdsForRedPoint(Integer companyId, Integer companyInfoId) throws SQLException;

	/**
     * 查询用户已处理的审批id
     *
     * @param companyId
     * @param companyInfoId
     * @param orderBy
     * @return
     * @throws SQLException
     */
    List<Integer> selectRequestIdsApprovedByCompanyInfoId(Integer companyId, Integer companyInfoId, String orderBy) throws SQLException;

	/**
	 * 查询用户批准的带红点的审批id集合
	 *
	 * @param companyId
	 * @param companyInfoId
	 * @param redRequestIds
	 * @return
	 * @throws SQLException
	 */
	List<Integer> selectRequestIdsApprovedByCompanyInfoIdWithRedPoint(Integer companyId, Integer companyInfoId, String redRequestIds) throws SQLException;
    /**
     * 批量修改审批流
     *
     * @param flowsAfterOrdering
     * @throws SQLException
     */
    void updateBatchFlow(List<Flow> flowsAfterOrdering) throws SQLException;

    /**
     * 彻底删除审批流
     *
     * @param oldFlowsToDelete
     * @throws SQLException
     */
    void deleteBatchFlows(List<Flow> oldFlowsToDelete) throws SQLException;

    /**
     * 批量获取审批流信息
     *
     * @param requestIds
     * @return
     * @throws SQLException
     */
    Map<Integer, List<Flow>> selectFlowMapByRequestIds(String requestIds) throws SQLException;

    /**
     * 根据审批id批量删除审批流
     *
     * @param companyId
     * @param requestIds
     */
    void deleteBatchFlowsByRequestIds(Integer companyId, String requestIds) throws SQLException;

}
